/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package com.maschinenstuermer.profiler.trace.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import com.maschinenstuermer.profiler.trace.CallStacksType;
import com.maschinenstuermer.profiler.trace.MethodsType;
import com.maschinenstuermer.profiler.trace.Trace;
import com.maschinenstuermer.profiler.trace.TracePackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Trace</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link com.maschinenstuermer.profiler.trace.impl.TraceImpl#getMethods <em>Methods</em>}</li>
 *   <li>{@link com.maschinenstuermer.profiler.trace.impl.TraceImpl#getCallStacks <em>Call Stacks</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class TraceImpl extends EObjectImpl implements Trace {
	/**
	 * The cached value of the '{@link #getMethods() <em>Methods</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMethods()
	 * @generated
	 * @ordered
	 */
	protected MethodsType methods;
	/**
	 * The cached value of the '{@link #getCallStacks() <em>Call Stacks</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCallStacks()
	 * @generated
	 * @ordered
	 */
	protected CallStacksType callStacks;
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected TraceImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return TracePackage.Literals.TRACE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MethodsType getMethods() {
		return methods;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetMethods(MethodsType newMethods, NotificationChain msgs) {
		MethodsType oldMethods = methods;
		methods = newMethods;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TracePackage.TRACE__METHODS, oldMethods, newMethods);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMethods(MethodsType newMethods) {
		if (newMethods != methods) {
			NotificationChain msgs = null;
			if (methods != null)
				msgs = ((InternalEObject)methods).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TracePackage.TRACE__METHODS, null, msgs);
			if (newMethods != null)
				msgs = ((InternalEObject)newMethods).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TracePackage.TRACE__METHODS, null, msgs);
			msgs = basicSetMethods(newMethods, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TracePackage.TRACE__METHODS, newMethods, newMethods));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public CallStacksType getCallStacks() {
		return callStacks;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetCallStacks(CallStacksType newCallStacks, NotificationChain msgs) {
		CallStacksType oldCallStacks = callStacks;
		callStacks = newCallStacks;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TracePackage.TRACE__CALL_STACKS, oldCallStacks, newCallStacks);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCallStacks(CallStacksType newCallStacks) {
		if (newCallStacks != callStacks) {
			NotificationChain msgs = null;
			if (callStacks != null)
				msgs = ((InternalEObject)callStacks).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TracePackage.TRACE__CALL_STACKS, null, msgs);
			if (newCallStacks != null)
				msgs = ((InternalEObject)newCallStacks).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TracePackage.TRACE__CALL_STACKS, null, msgs);
			msgs = basicSetCallStacks(newCallStacks, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TracePackage.TRACE__CALL_STACKS, newCallStacks, newCallStacks));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case TracePackage.TRACE__METHODS:
				return basicSetMethods(null, msgs);
			case TracePackage.TRACE__CALL_STACKS:
				return basicSetCallStacks(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case TracePackage.TRACE__METHODS:
				return getMethods();
			case TracePackage.TRACE__CALL_STACKS:
				return getCallStacks();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case TracePackage.TRACE__METHODS:
				setMethods((MethodsType)newValue);
				return;
			case TracePackage.TRACE__CALL_STACKS:
				setCallStacks((CallStacksType)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case TracePackage.TRACE__METHODS:
				setMethods((MethodsType)null);
				return;
			case TracePackage.TRACE__CALL_STACKS:
				setCallStacks((CallStacksType)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case TracePackage.TRACE__METHODS:
				return methods != null;
			case TracePackage.TRACE__CALL_STACKS:
				return callStacks != null;
		}
		return super.eIsSet(featureID);
	}

} //TraceImpl
